
import React, { Component } from 'react';
import { inject, observer } from 'mobx-react';

import { Modal, Button, Spin } from 'antd';


@inject('HumanBodyManageStore')
@observer
export default class Remind extends React.Component {
    constructor(props) {
        super(props);
        this.state = { visible: props.visible };
        console.log(props)
    }

    componentWillReceiveProps(nextProps) {
        console.log(nextProps)
        if (nextProps.type === 'photo') {

        } else {
            if (nextProps.visible === true) {
                this.setState((prevState) => ({
                    visible: true
                }))
            } else {
                this.setState((prevState) => ({
                    visible: false
                }))
            }
        }

    }
    showModal = () => {
        this.setState({
            visible: true,
        });
    };
    handleOk = e => {
        console.log(e);
        this.setState({
            visible: false,
        });
        this.props.HumanBodyManageStore.change_created_task(false)
    };

    handleCancel = e => {
        console.log(e);
        this.setState({
            visible: false,
        });
        this.props.HumanBodyManageStore.change_created_task(false)
    };

    render() {
        console.log(this.props.type)
        return (
            <div>
                <Button type="primary" onClick={this.showModal} style={{ display: "none" }}>
                    Open Modal
                </Button>
                <Modal
                    title=""
                    visible={this.state.visible}
                    onOk={this.handleOk}
                    onCancel={this.handleCancel}
                    centered
                    wrapClassName="no_height  upload_photo "
                    width="400px"
                    okText=""
                >{
                        this.props.type === 'photo' ? <Spin tip="后台正在处理图片上传请求..." className="upload_remind_icon" >
                        </Spin> : <div style={{ textAlign: "left" }}>您有视频入库任务提交，请点击显示刷新按钮查看最新人体库信息</div>
                    }
                </Modal>
            </div>
        );
    }
}

